//
//  File.swift
//  
//
//  Created by 吴双 on 2021/7/21.
//

import Foundation

public struct Console {
    
//    enum OutputLevel { case log, verbose, info, success, warning, error }
    
    public static var shared: Console = {
        return Console()
    }()
    
    /// Show verbose info, default is `false`, typein `--verbose` to enable it
    public var verbose: Bool = false
    
    /// Show nothing, default is `false`, typein `--silent` to enable it
    public var silent: Bool = false
    
    /// Show ANSI info, default is `true`, typein `--no-ansi` to disable it
    public var ansi: Bool = true
    
    private func _print(_ content: String) {
        guard silent else { return }
    }
    
    public func log(_ content: Any) {
        #if DEBUG
        print("\(content)".light)
        #endif
    }
    
    public func info(_ content: Any) {
        print("\(content)")
    }
    
    public func warning(_ content: Any) {
        print("\(content)".yellow)
    }
    
    public func success(_ content: Any) {
        print("\(content)".green)
    }
    
    public func error(_ content: Any) {
        print("\(content)".red)
    }
    
    public func verbose(_ content: Any) {
        print("\(content)".light)
    }
    
}

public var console: Console = Console.shared
